<script setup lang="ts">
import {getHashSearchParam, getUrlParam} from '@/utils/param'
import {NButton} from 'naive-ui'
import {useRouter} from 'vue-router'

const router = useRouter()

function goHome() {
	router.push('/')
}

const success = ref<boolean>(false)
const errorMessage = ref<string>('系统异常')
onMounted(() => {
	success.value = getHashSearchParam('success', window.location.href) == 'true'
	errorMessage.value = getHashSearchParam('error_message', window.location.href) || '系统异常'
	// console.log(unref(success))
	// console.log(unref(errorMessage))
})
</script>

<template>

	<div class="flex h-full">
		<div class="px-4 m-auto space-y-4 text-center max-[400px]">
			<h1 class="text-4xl text-slate-800 dark:text-neutral-200">
				欢迎使用忻宇ai
			</h1>
			<div v-if="success">
				<div class="flex items-center justify-center text-center" style="margin-top: 10px">
					<div class="w-[300px]">
						<n-result status="success" title="验证成功" description="您可以使用邮箱进行登录啦！">
							<template #footer>
								<n-button @click="goHome">回到首页</n-button>
							</template>
						</n-result>
					</div>
				</div>
			</div>
			<div v-else>
				<div class="flex items-center justify-center text-center" style="margin-top: 10px">
					<div class="w-[300px]">
						<n-result status="warning" title="验证失败" :description="errorMessage">
							<template #footer>
								<n-button @click="goHome">回到首页</n-button>
							</template>
						</n-result>
					</div>
				</div>
			</div>
		</div>
	</div>

</template>

<style scoped lang="less">

</style>
